package com.ruoyi.peizhen.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.peizhen.domain.BusinessBindserver;
import com.ruoyi.peizhen.service.IBusinessBindserverService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务医院绑定Controller
 * 
 * @author ruoyi
 * @date 2022-03-13
 */
@Controller
@RequestMapping("/peizhen/bindserver")
public class BusinessBindserverController extends BaseController
{
    private String prefix = "peizhen/bindserver";

    @Autowired
    private IBusinessBindserverService businessBindserverService;

    @RequiresPermissions("peizhen:bindserver:view")
    @GetMapping()
    public String bindserver()
    {
        return prefix + "/bindserver";
    }

    /**
     * 查询业务医院绑定列表
     */
    @RequiresPermissions("peizhen:bindserver:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BusinessBindserver businessBindserver)
    {
        startPage();
        List<BusinessBindserver> list = businessBindserverService.selectBusinessBindserverList(businessBindserver);
        return getDataTable(list);
    }

    /**
     * 导出业务医院绑定列表
     */
    @RequiresPermissions("peizhen:bindserver:export")
    @Log(title = "业务医院绑定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BusinessBindserver businessBindserver)
    {
        List<BusinessBindserver> list = businessBindserverService.selectBusinessBindserverList(businessBindserver);
        ExcelUtil<BusinessBindserver> util = new ExcelUtil<BusinessBindserver>(BusinessBindserver.class);
        return util.exportExcel(list, "业务医院绑定数据");
    }

    /**
     * 新增业务医院绑定
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存业务医院绑定
     */
    @RequiresPermissions("peizhen:bindserver:add")
    @Log(title = "业务医院绑定", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BusinessBindserver businessBindserver)
    {
        return toAjax(businessBindserverService.insertBusinessBindserver(businessBindserver));
    }

    /**
     * 修改业务医院绑定
     */
    @RequiresPermissions("peizhen:bindserver:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BusinessBindserver businessBindserver = businessBindserverService.selectBusinessBindserverById(id);
        mmap.put("businessBindserver", businessBindserver);
        return prefix + "/edit";
    }

    /**
     * 修改保存业务医院绑定
     */
    @RequiresPermissions("peizhen:bindserver:edit")
    @Log(title = "业务医院绑定", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BusinessBindserver businessBindserver)
    {
        return toAjax(businessBindserverService.updateBusinessBindserver(businessBindserver));
    }

    /**
     * 删除业务医院绑定
     */
    @RequiresPermissions("peizhen:bindserver:remove")
    @Log(title = "业务医院绑定", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(businessBindserverService.deleteBusinessBindserverByIds(ids));
    }
}
